Hello and welcome him.
They feed you.
I will be adding the javascript functionality that will make the application work.
So let's create our javascript farm.
We've already made a reference to it inside our script from the Hey Tim a file and a poor deep quartz
Duchess.
Someone to click on a file option in sublime Tex.
Go new.
And I'm going to save this new file.
Java script files.
I'm going to call it quits g s and to select the drop down here.
Make sure I select.
He checked my scrip far.
All right so I'll say that.
So I now have a javascript file send anything you can see here on the bottom right hand corner says
javascript as well.
The first thing I want to do is create an array.
And now really am going to use the every tool hold the values of the quotes so to define our and a first
for create a variable.
OK call the artful variable and I'm going to call it Harry off quotes.
Note is the use of -- will case come will cause.
Basically means the first letter of the first word is lower case and then the first letter of or the
subsequent words are in upper case.
He can see the all his PA and the Q in chords is up right.
Some will accept that to equal to an array.
This is how you define an array in square brackets.
So in between this array here is where I'm going to place the books so you can select your own favourite
quotes.
You don't have to use mine so these are just some of my favourite quotes.
I'm going to just paste that him inside this Arri.
So these are the quotes that will be randomly generated when you click on the button so they're good
having close them inside an array you can see that the opening array which is the square bracket and
this is the closing array.
So does good true.
Just one of the quotes I got through the first one here so you can see here.
I got to Arthur because the text.
We need to include text in quotes.
Some got it off or here and after that I got a call on and then we have the name of the author and then
a comma.
Notice I have enclosed everything inside opening curly braces and closing curly braces and there is
a comma which is important whenever you put a comma.
That means you've got more to come.
So here this is the first quote here.
This is the second quote so h in between is curly braces.
You have to offer and then you have the name of the offer and then you have the actual quote itself.
Notice is very important to note is the chords are closed.
Each of the parts.
So the aha.
You've got quotes and then call on and then you've got the output of what you've got chords rounded
and then come very important because you miss out the comma.
It will not work properly so make sure you place a comma after each of the hotels name and then comma.
Also at the end of the closing calibrates this is the only place where you don't need to place a comma
is the final curly braces.
So the last quote You don't need to put a comma on the last curly braces or the others.
Put a comma up but the loss very important.
But you must put a comma after the name of the author.
All right so we got voler Use just a sample here.
You can make these as long as you want add as many quotes as you want as long as you have it in close
inside the hurry.
That should be fine.
Also make sure that each of the auto name has a comma after the name.
Put a comma.
I've tidied Kobe braces put a comma behind the plate is only the comma is the last is the last of.
So this is the.
Last one here so I don't need a curlee DONE.
However if I decided I wanted to add more quotes on then I would need took place.
They've come out there and add more coats.
So that is the tree.
The next thing I want to do is create a function that wall rung donnelly select each of the quotes using
the length of the ring and we are going to be using the maths random method and I will lend basically
refers to the values inside the array.
It begins with is zero index So for example this one here will be referred to as 0 1 2 3 4 and so on.
So just underneath the close in array here add a function of cordy's Random select and I've passed it
this parameter out of our real length our relend basically ref determines or makes reference to the
values inside the rate.
So the very first value is going to be zero.
This would be 0 1 2 3 4 and so on.
That's what the relend is referring to and is going to return a value it's going to return mass floor
mass of flood basically is going to be to around in number downwards to is near S integer.
All right so the masteroff floor rounded number up to the nearest integer M. at random or randomly generate
random numbers based on the re length.
So next time I want to do is create a function Hord generate quote.
So if we look inside the hate mail here we already made reference to this function code generate code.
This is going to be this function here is already attached to the button which is the unclick method
so when you click on the button it will call this function so that's a function.
I am going to create now just going to add it on the the random select off are right so I added a function
call.
Generate quote.
So this is a function that will be called upon.
When you click on the button inside the hastier mail so the name is generate quotes and in between the
curly braces is the code that will execute.
So here we've got a variable called random number and I've set that too of course for the random select
which is this function here and then inside the parentheses part in the Re.
Of course the array of quotes is this variable.
Here I have created some passing that value has a parameter bear and I attached the left leg.
Basically it will determine how many awards there are in the array.
So the very first call would be zero.
And the last or B.
So you start from zero and one saw.
Okay so the Lend Me refers to the length of the courts have this how many quotes you have in the array.
That's what that means.
And then we use in the document to get a lemon about a Dementor out.
So this basically which is a quote outport in this here is inside his team which is this quote put here.
That's what's his refrain to us all we getting that idea called Court our.
And we are replacing it content with this in the hastier mail yes you see here this code here.
Basically we are replacing it with the quotes that will be generated create to create a space plus the
array of quotes which is this here plus the random number.
Okay so each of the quotes will be a randomly assigned number based on the length of the quotes in the
array.
So the random number will be.
So he told for example he can randomly select this or 4 here or this quote and it all.
Then attach the quote bloss whatever the court says and then here Line 6 is to again we use the documents
element.
Here we are going to.
This is where we're going to put the author.
Okay so if we go into the hastier mail we've got this idea here.
So basically it all Take all that this paragraph and inject the author here.
That's what that is.
So who's going to just replace.
Whatever content you have inside this paragraph all these idae and replace it will be actual quote and
the OT and the name of the heart or so to grab the quote from the random number assigned to the court
and also attach the name of the author to the court.
So that's basically what this function with.
So this is the function that would do a lot of the heavy lifting for the application time because looks
look on the save option and then we can test the application someone to click on the tree here
and double click on the quotes hastier CML when youre running your projet you always have to run the
hastier mouth not the SS or the javascript.
They are already linked to the hedge titmouse or double click on the team now and you issue get the
application like.
So this is the application now.
So if everything works out fine.
If there are no errors in my javascript I should be able to click on the button.
You can see the keywords generated in C.
Right so everything is working.
Has design.
Okay so if I click I get a new word each time so that is it for this application.
Thank you for watching.
If you have any problems please to let me know.
Thanks.
All the best.